package classes.multithread;

/**
 * @author : DuJiabao
 * @Date : 2021/1/19 19:57
 * @Project : java_learning
 * @File : null.java
 * @Desc : 方法一：继承Thread类
 */
public class ThreadTest {
    public static void main(String[] args) {
        MyThread thread1 = new MyThread();
        thread1.setName("Thread 1");
        MyThread thread2 = new MyThread();
        thread2.setName("Thread 2");
        thread1.start();
        thread2.start();
    }
}

class MyThread extends Thread {
    @Override
    public void run() {
        super.run();
        for (int i = 0; i < 1000; i++) {
            System.out.println(Thread.currentThread().getName() + " " + i);
        }
    }
}

